[DllImport("DIFxAPI.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern Int32 DriverPackageInstall([MarshalAs(UnmanagedType.LPTStr)] string DriverPackageInfPath, Int32 Flags, IntPtr pInstallerInfo, out bool pNeedReboot);
Public Declare Auto Function DriverPackageInstall Lib "DIFxAPI.dll" (ByVal DriverPackageInfPath As String, ByVal Flags As Int32, ByVal pInstallerInfo As IntPtr, ByRef pNeedReboot As Boolean) As Int32
None.
Do you know one? Please contribute it!
None.
To use this function you just need difxapi.dll of appropriate architecture from Windows Server 2008/Vista WDK. The DriverStore will be created automatically for you.
C#:
Int32 Flags = DRIVER_PACKAGE_SILENT | DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT | DRIVER_PACKAGE_LEGACY_MODE;
bool fNeedReboot;
INSTALLERINFO installerInfo = new INSTALLERINFO();
installerInfo.pApplicationId = "{4d36e972-e325-11ce-bfc1-08002be10319}";
installerInfo.pDisplayName = "My Package";
installerInfo.pProductName = "My Package";
installerInfo.pMfgName = "Myself";
IntPtr ptrInstallerInfo = Marshal.AllocHGlobal(Marshal.SizeOf(installerInfo));
Marshal.StructureToPtr(installerInfo, ptrInstallerInfo, false);
Int32 InstallResult = DriverPackageInstall(infFile, Flags, ptrInstallerInfo, out fNeedReboot);
Marshal.FreeHGlobal(ptrInstallerInfo);
VB:
Dim fNeedReboot As Boolean
Dim installerInfo As INSTALLERINFO = New INSTALLERINFO()
installerInfo.pApplicationId = "{4d36e972-e325-11ce-bfc1-08002be10319}"
installerInfo.pDisplayName = "My Package"
installerInfo.pProductName = "My Package"
installerInfo.pMfgName = "Myself"
Dim ptrInstallerInfo As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(INSTALLERINFO))
Marshal.StructureToPtr(INSTALLERINFO, ptrInstallerInfo, False)
Dim InstallResult As Int32 = DriverPackageInstall(infFile, Flags, ptrInstallerInfo, fNeedReboot)
Marshal.FreeHGlobal(ptrInstallerInfo)